<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/12 0012
 * Time: 下午 3:55
 */

namespace ServiceClass;


use Illuminate\Support\Facades\DB;
use ToolClass\PageClass;
use Illuminate\Support\Facades\Redis;
use ServiceClassInterface\ArticleContract;

class Article implements ArticleContract
{
    public function addArticle($articleData)
    {

        $articleData['article_CreateTime'] = date('Y-m-d');
        $result = DB::table('article')->insert($articleData);
        if($result){

            return 1;
        }else{

            return 0;
        }

    }

    public function deleteArticle($articleData)
    {

        $result = DB::table('article')->where('article_id',$articleData)->delete();
        if($result){

            return 1;
        }else{

            return 0;
        }
    }

    public function searchArticle($articleData)
    {

        $result = DB::table('article')->where('article_id',$articleData)->get();
        if($result){

            return $result;
        }else{

            return 0;
        }
    }

    public function selectArticleList($table,$limit,$where,$page)
    {

        $result = PageClass::Page($table,$limit,$where,$page);


        return $result;

    }

    public function updateArticle($articleData)
    {

        $articleData['article_UpdateTime'] = date('Y-m-d');
        $result = DB::table('article')->where('article_id',$articleData['article_id'])->update($articleData);
        if($result){

            return 1;
        }else{

            return 0;
        }
    }
}